
class Timer():
    MINUTE=60000
    SECOND=1000
    def __init__( self, pos, duration=1):
        self.set_time(0,0,0)
	self.set_duration(duration)
	self.last_blitted_s=None
	self.__pos=pos

    def set_time( self, m, s, ms):
	self.__ms = (m*60000)+(s*1000)+ms    
        
    def get_minutes_part(self):
        return int(self.__ms/self.MINUTE)
    def get_seconds_part(self):
	#less get minute
        return int((self.__ms-self.get_minutes_part()*self.MINUTE)/self.SECOND)
    def get_seconds_tot(self):
     	return int(self.__ms/self.SECOND) 
    def get_ms(self):
	return self.__ms
 
    def add_minute(self,m):
        self.__ms = self.__ms+(m*self.MINUTE)
        
    def add_second(self,s):
        self.__ms = self.__ms+(m*self.SECOND)
            
    def add_millisecond(self,ms):
        self.__ms = self.__ms+ms

    def set_duration(self, duration=1):
	self.__duration=duration
    
    def reset(self):
        self.set_time(0,0,0)
        
    def __str__(self):
        return '%(minute)d:%(second)02d/%(duration)d:00' % {'minute': self.get_minutes_part(), 'second': self.get_seconds_part(), 'duration':self.__duration}
     
    def blit_to( self, screen, font):
#	if (self.get_seconds_tot() != self.last_blitted_s):
	s= font.render( self.__str__(), 1, (255,255,255),(0,0,0))
	screen.blit(s, (self.__pos[0]-s.get_rect().width/2,self.__pos[1]))
#		self.last_blitted_s= self.get_seconds_tot()
